package edu.gatech.ors.mrsim.io.conf;

public class BasicLoader implements ConfigurationClassLoader {

    @Override
    public Class<?> loadClass(String key, Configuration from)
	    throws ClassNotFoundException {
	if (key != null && !from.containsKey(key))
	    return null;
	return Class.forName(from.getProperty(key));
    }

    @Override
    public Class<?>[] loadClasses(String key, Configuration from)
	    throws ClassNotFoundException {
	if (key != null && !from.containsKey(key))
	    return null;
	String[] names = from.getClassStrings(key);
	if (names != null) {
	    Class<?>[] classes = new Class<?>[names.length];
	    for (int i = 0; i < names.length; i++)
		classes[i] = Class.forName(names[i]);
	    return classes;
	}
	return null;
    }
}
